<style>
	
</style>
<template>
<div>
    <Card :bordered="false" dis-hover>
        <p slot="title">发票认证、查验</p>
        <Row :gutter="20">
			<Col span="6">
				<Input v-model="search.paramData.invoiceno" placeholder="发票号" ></Input>
			</Col>
			
			<Col span="2">
				<Button type="primary" icon="ios-search" @click="getdata('search')">搜索</Button>
			</Col>
       	</Row>
       	<div style="margin-top:20px;">
       		<div class="ivu-table-wrapper" >
	            <div class="ivu-table ivu-table-with-fixed-top ">
	                <div class="ivu-table-body" >
	                    <table  class="table_border _table"   cellspacing="0" cellpadding="0" border="0" style="width: 100%;">
		                   
		                    <thead>
			                    <tr>
			                        <th class="">
			                            <div class="ivu-table-cell">
			                                <span>发票号</span>
			                            </div>
			                        </th>
			                        <th class="" style="width:90px;">
			                            <div class="ivu-table-cell">
			                                <span>开票日期</span>
			                            </div>
			                        </th>
			                        <th class="">
			                            <div class="ivu-table-cell">
			                                <span>销方名称</span>
			                            </div>
			                        </th>
			                        <th class="">
			                            <div class="ivu-table-cell">
			                                <span>价税合计&nbsp;(元)</span>
			                            </div>
			                        </th>
			                        <th class="">
			                            <div class="ivu-table-cell">
			                                <span>开票人</span>
			                            </div>
			                        </th>
			                        <th class="" style="width:80px;">
			                            <div class="ivu-table-cell">
			                                <span>认证状态</span>
			                            </div>
			                        </th>
									<th class="" style="width:80px;">
			                            <div class="ivu-table-cell">
			                                <span>查验状态</span>
			                            </div>
			                        </th>
			                        <th class="" style="width:110px;">
			                            <div class="ivu-table-cell">
			                                <span>	操作</span>
			                            </div>
			                        </th>
			                    </tr>
		                    </thead>
		                    <tbody class="ivu-table-tbody">
			                    <tr class="ivu-table-row"  v-for="item in data">
			                         <td class="">
			                            <div class="ivu-table-cell">
			                                <span>{{item.invoiceNo}}</span>
			                            </div>
			                        </td>
			                        <td class="">
			                            <div class="ivu-table-cell">
			                                <span>{{item.invoiceDate  | formatDate('yyyy-MM-dd')}}</span>
			                            </div>
			                        </td>
			                        <td class="">
			                            <div class="ivu-table-cell">
			                                <span>{{item.sellerName}}</span>
			                            </div>
			                        </td>
			                        <td class="">
			                            <div class="ivu-table-cell">
			                                <span>	{{item.invoiceTotalPriceTax}}</span>
			                            </div>
			                        </td>
			                        <td class="">
			                            <div class="ivu-table-cell">
			                                <span>{{item.drawer}}</span>
			                            </div>
			                        </td>
			                        <td class="">
			                            <div class="ivu-table-cell">
			                                <span  class="spanc_r">
			                                	
			                                {{item.rzFlag | decode('rzflag')}}</span>
			                            </div>
			                        </td>
									 <td class="">
			                            <div class="ivu-table-cell">
			                                <span  class="spanc_r" :style="item.checkFlag |decode('flag_color_2')">{{item.checkFlag | decode('flag')}}</span>
			                            </div>
			                        </td>
			                        <td class="">
			                            <div class="ivu-table-cell">
			                                <!-- <Button  size="small" @click="show()">查看</Button> -->
			                                <Button  size="small" @click="check(item)"
			                                v-if="pre.indexOf('auth')>-1">认证</Button>
			                                <Button  size="small" @click="checkb(item)"
			                                v-if="pre.indexOf('validate')>-1">查验</Button>
			                            </div>
			                        </td>
			                    </tr>
		                    </tbody>
	                    </table>
	                    <div class="body_empty" v-if="data.length==0 ">
	                    	暂无数据
	                    </div>
	                </div>
	            </div>
	            
	        </div>
       	</div>
       	<div style="margin-top:20px;">
       		
       		<Page  show-total :page-size="search.pageSize"	:total="pageParams.total" 
       		show-total @on-change="changePage" style="float:right;"></Page>
       	</div>
    </Card>
    <Modal v-model="modal" width="800">
        <img src="../../assets/images/1.png" style="width:100%;">
        <p slot="footer" ></p>
    </Modal>
    <auth-edit @refresh="getdata"></auth-edit>
</div>	
</template>
<script>
import AuthEdit from "../Module/authedit.vue"
export default {
	components:{AuthEdit},
	data (){
		return {
			modal:false,
			search:{paramData:{invoiceno:''},pageNo:1,pageSize:10},
			states:['真','未'],
			pageParams:{total:0},
			data:[
				
			]
		}
	},methods:{
		changePage (pageNum){
			this.search.pageNo = pageNum;
     		this.getdata();
		},getdata(type){
			if(type=='search'){
				this.search.pageNo=1;
			}
			this.axios.post('/incomeinvoice/queryInvoice',
				this.search).then((res)=>{
				console.log(res);
				var d=res.data.list;
				for(var i=0;i<d.length;i++){
					d[i].show=false;
				}
				this.data=d;
				this.pageParams.total=res.data.total;
				this.pageParams.pageSize=res.data.pageSize
				this.search.pageNo=res.data.pageNo || 1;
			})
		},show(){
			this.modal=true;
		},check(item){
			this.$Modal.confirm({
                 title:'提示',
                 content: '<p>确定验证？</p>',
                 loading:true,
                 onOk:()=>{
                 	this.axios.post('/incomeinvoice/deductible',
						{invoiceGuid:item.guid}).then((res)=>{
							console.log(res);
							this.$Modal.remove();
							if(res.errorCode==0){
								this.$Message.success(res.message);
								this.getdata();
							}else{
								//this.$Message.error(res.message);
							}

					}).catch((err)=>{
						this.$Modal.remove();
						//console.log(err)
					
					})
                }
            })
				
		},checkb(item){
			this.$Modal.confirm({
                 title:'提示',
                 content: '<p>确定查验？</p>',
                 loading:true,
                 onOk:()=>{
					this.axios.post('/incomeinvoice/validate',
						{invoiceGuid:item.guid,invoiceType:'income'}).then((res)=>{
							this.$Modal.remove();
							console.log(res);
							
							if(res.errorCode==0){
								//this.$Message.success(res.message);
								//this.getdata();
								var u=res.data;
								u.guid=item.guid;
								this.$bus.emit('bus_authsedit',u)
							}else{
								//this.$Message.error(res.message);
							}

					})
                }
            })
			
		}
	},mounted(){
		$('._table').resizableColumns({});
	},created(){
		this.getdata();
	},activated(){
		this.getdata();
	},computed:{
        pre(){
            return this.$store.getters.getUserinfo.permList.join('')
        }
    }
}
</script>